(function($){
	$(document).ready(function(){
		if($('.dt-shop-load-items').length > 0) {
			$('.dt-shop-load-items').click(function(event){
				var parent = $(this).closest('.dt-shop-portfolio');
				var filter = parent.find('.dt-shop-filter').find('.active');
				var tid = filter.attr('data-filter');
				var pager = filter.attr('data-pager');
				var url_load = Drupal.settings.basePath + '?q=shop/load-more';
				if(pager != '-1') {
					pager = parseInt(pager) + 1;
					url_load = url_load + '/' + tid + '/' + pager;
					$.ajax({
						url: url_load,
						success: function(data){
							if(data == '-1') {
								filter.attr('data-pager', '-1');
							} else {
								parent.find('.data-grid-' + tid).append(data);
								filter.attr('data-pager', pager);
							}
						}
					});
				}
				event.preventDefault();
			});
		}
	});
})(jQuery);
